import java.io.FileNotFoundException;

public class Main {

	public static void main(String[] args) throws FileNotFoundException {

		// Prime number for hash
		int h = 2;
		// Noise size : k
		int k = 50;
		// Minimum size to guarentee a match : t
		int t = 70;

		System.out.println("Reading...\n");

		boolean single = false;
		boolean show = false;
		SteamString s=new SteamString();
		for (int i = 0; i < args.length; i++) {	

			if (args[i].equals("--show")) {
				show = true;
			}
			if (args[i].equals("--single")) {
				single = true;
			}
			if (args[i].equals("-h")) {
				try {
					h = Integer.parseInt(args[i+1]);
				} catch (NumberFormatException e) {
					System.err.println("Argument -h must be an integer");
				}
			}
			if (args[i].equals("-k")) {
				try {
					k = Integer.parseInt(args[i+1]);
				} catch (NumberFormatException e) {
					System.err.println("Argument -k must be an integer");
				}
			}
			if (args[i].equals("-t")) {
				try {
					t = Integer.parseInt(args[i+1]);
				} catch (NumberFormatException e) {
					System.err.println("Argument -t must be an integer");
				}
			}
			else {
				Read.readDirectory(args[i], s);
			}
			
		}
		// Window size for winnowing
		int w = t - k + 1;

		System.out.println("Finished reading\n");

		if (s.isEmpty()) {
			System.out.println("No files found");
		}
		else {
			System.out.println("Normalizing and Hashing...\n");

			Compare.compareDirectory(s, k, h, w, show, single);

			System.out.println("Done");
		}

	}

}